<div id="dhh-push-msg" class="show_page_content">

    <div id="container" name="content" style="width:80%;margin-top:30px;maigin-left:10%;height:70%;float: left;"></div>
    <div class="layui-btn input-line-1" id="dhh-push-msg-add-btn" style="margin-top:20px;margin-bottom: 50px;">
        <i class="layui-icon layui-icon-add-circle-fine"></i>提交</div>

    <div class="layui-btn input-line-1" id="dhh-push-msg-clear-btn" style="margin-top:20px;margin-bottom: 50px;">
        <i class="layui-icon layui-icon-add-circle-fine"></i>清空</div>
</div>
<script type="text/javascript">
    var ue = UE.getEditor('container');
    $("#dhh-push-msg-clear-btn").on("click", function() {
        var clear = layer.confirm("确定清空内容？", {
            icon: 0
        }, function() {

            ue.execCommand('cleardoc');
            layer.close(clear);
        });
    });
    $("#dhh-push-msg-add-btn").on("click", function() {
        var html = ue.getContent();
        ///msg/msg_post
        $.ajax({
            url: "/msg/msg_post",
            data: {
                content: html
            },
            type: "post",
            dataType: "json",
            beforeSend: function() {
                loadIndex = layer.load(0);
            },
            success: function(d) {
                layer.close(loadIndex);
                if (d.result == "1") {
                    layer.msg("提交成功！", {
                        icon: 1,
                        time: 2000
                    });
                    ue.execCommand('cleardoc');
                } else {
                    layer.msg("提交失败！", {
                        icon: 1,
                        time: 2000
                    });
                }

            },
            error: function() {
                layer.msg("提交网络异常！", {
                    icon: 1,
                    time: 2000
                });
            }
        })
    });
</script>